home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 04 / 4 / DISK0442.ZIP / TIMEDAT3.PAS < prev    next >
Pascal/Delphi Source File  |  1985-11-26  |  2KB  |  58 lines

  1. function clock: TDString;
  2. type
  3.   regpack = record
  4.               ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  5.             end;
  6.  
  7. var
  8.   recpack:          regpack;             {assign record}
  9.   ah,al,ch,cl,dh:   byte;
  10.   hour,min,sec:     string[2];
  11.  
  12. begin
  13.   ah := $2c;                             {initialize correct registers}
  14.   with recpack do
  15.   begin
  16.     ax := ah shl 8 + al;
  17.   end;
  18.   intr($21,recpack);                     {call interrupt}
  19.   with recpack do
  20.   begin
  21.     str(cx shr 8,hour);                  {convert to string}
  22.     str(cx mod 256,min);                       { " }
  23.     str(dx shr 8,sec);                         { " }
  24.       if length(min)=1 then min:='0'+min;
  25.       if length(sec)=1 then sec:='0'+sec
  26.   end;
  27.   clock := hour+':'+min+':'+sec;
  28. end;
  29. function Date: TDString;
  30. type
  31.   regpack = record
  32.               ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  33.             end;
  34.  
  35. var
  36.   recpack:       regpack;                {record for MsDos call}
  37.   month,day:     string[2];
  38.   year:          string[4];
  39.   dx,cx:         integer;
  40.  
  41. begin
  42.   with recpack do
  43.   begin
  44.     ax := $2a shl 8;
  45.   end;
  46.   MsDos(recpack);                        { call function }
  47.   with recpack do
  48.   begin
  49.     str(cx,year);                        {convert to string}
  50.     str(dx mod 256,day);                     { " }
  51.     str(dx shr 8,month);                     { " }
  52.   end;
  53.   if length(day)=1 then day:='0'+day;
  54.   if length(month)=1 then month:='0'+month;
  55.   Delete(year,1,2);
  56.   date := month+'/'+day+'/'+year;
  57. end;
  58.